package com.zzyl.service.impl;

import cn.hutool.crypto.digest.BCrypt;
import com.zzyl.dto.LoginDto;
import com.zzyl.mapper.UserMapper;
import com.zzyl.service.UserService;
import com.zzyl.vo.LoginVo;
import com.zzyl.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Learner
 * @Version: 1.0
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserVo login(LoginDto loginDto) {
        String password = loginDto.getPassword();
        UserVo userVo = userMapper.login(loginDto);
        if (BCrypt.checkpw(password, userVo.getPassword())) {
            log.info("密码验证成功");
            return userVo;
        }
        return null;
    }

    /*BCrypt 加密方式
    String hashedPassword = BCrypt.hashpw(password, BCrypt.gensalt());
    * */

}
